package zhongbo.java.air.dictionary.model;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;
import zhongbo.java.air.dictionary.model.enums.AirPortStatus;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.PastOrPresent;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
@ApiModel("机场信息")
@TableName("air_airport")
public class AirPort {
    @TableId(type = IdType.ASSIGN_UUID)
    @ApiModelProperty(value = "主键id", example = "1")
    @Size(min = 1, max = 36, message = "主键ID长度必须在1到36字符之间")
    @NotNull(message = "主键不能为空")
    private String id;

    @ApiModelProperty(value = "ICAO机场代码", example = "ZBAA")
    @TableField("icao_code")
    @Size(min = 1, max = 4, message = "ICAO代码长度必须在1到4字符之间")
    @NotNull(message = "ICAO代码不能为空")
    private String icaoCode;

    @ApiModelProperty(value = "IATA代码", example = "PEK")
    @TableField("iata_code")
    @Size(min = 1, max = 3, message = "IATA代码长度必须在1到3字符之间")
    @NotNull(message = "IATA代码不能为空")
    private String iataCode;

    @ApiModelProperty(value = "机场全称", example = "xx航空")
    @TableField("name")
    @Size(min = 1, max = 100, message = "机场名称长度必须在1到100字符之间")
    @NotNull(message = "机场名称不能为空")
    private String name;

    @ApiModelProperty(value = "纬度", example = "11.0001")
    @TableField("latitude")
    @NotNull(message = "纬度不能为空")
    private Double latitude;

    @ApiModelProperty(value = "经度", example = "11.0001")
    @TableField("longitude")
    @NotNull(message = "经度不能为空")
    private Double longitude;

    @ApiModelProperty(value = "状态", example = "OPERATIONAL")
    @TableField("status")
    @Pattern(regexp = "^(OPERATIONAL|CLOSED|RESTRICTED)$", message = "状态必须是 OPERATIONAL, CLOSED 或 RESTRICTED")
    @NotNull(message = "状态不能为空")
    private AirPortStatus status;

    @ApiModelProperty(value = "时区", example = "Asia/Beijing")
    @TableField("timezone")
    @Size(min = 1, max = 50, message = "时区长度必须在1到50字符之间")
    @NotNull(message = "时区不能为空")
    private String timezone;

    // 日期类型字段无需添加 @Size
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "创建时间", example = "2025-03-31 20:10:18")
    @TableField("create_time")
    @PastOrPresent(message = "创建时间必须是过去或现在")
    private Date createTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    @ApiModelProperty(value = "更新时间", example = "2025-03-31 20:10:18")
    @TableField("update_time")
    @PastOrPresent(message = "创建时间必须是过去或现在")
    private Date updateTime;
}
